/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author tofy
 */
@Entity
@Table(name = "Diario", catalog = "Gastos", schema = "")
@NamedQueries({
    @NamedQuery(name = "Diario.findAll", query = "SELECT d FROM Diario d"),
    @NamedQuery(name = "Diario.findByDiarioID", query = "SELECT d FROM Diario d WHERE d.diarioID = :diarioID"),
    @NamedQuery(name = "Diario.findByFecha", query = "SELECT d FROM Diario d WHERE d.fecha = :fecha"),
    @NamedQuery(name = "Diario.findByImporte", query = "SELECT d FROM Diario d WHERE d.importe = :importe"),
    @NamedQuery(name = "Diario.findByConcepto", query = "SELECT d FROM Diario d WHERE d.concepto = :concepto"),
    @NamedQuery(name = "Diario.findByPagado", query = "SELECT d FROM Diario d WHERE d.pagado = :pagado")})
public class Diario implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "DiarioID", nullable = false)
    private Long diarioID;
    @Column(name = "Fecha")
    @Temporal(TemporalType.DATE)
    private Date fecha;
    @Column(name = "Importe", precision = 22)
    private Double importe;
    @Column(name = "Concepto", length = 255)
    private String concepto;
    @Basic(optional = false)
    @Column(name = "Pagado", nullable = false)
    private boolean pagado;
    @JoinColumn(name = "UsuarioID_fk", referencedColumnName = "UsuarioID")
    @ManyToOne
    private Usuarios usuarioIDfk;
    @JoinColumn(name = "Cta_ID_fk", referencedColumnName = "CtaID")
    @ManyToOne
    private Cuentas ctaIDfk;

    public Diario() {
    }

    public Diario(Long diarioID) {
        this.diarioID = diarioID;
    }

    public Diario(Long diarioID, boolean pagado) {
        this.diarioID = diarioID;
        this.pagado = pagado;
    }

    public Long getDiarioID() {
        return diarioID;
    }

    public void setDiarioID(Long diarioID) {
        this.diarioID = diarioID;
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    public Double getImporte() {
        return importe;
    }

    public void setImporte(Double importe) {
        this.importe = importe;
    }

    public String getConcepto() {
        return concepto;
    }

    public void setConcepto(String concepto) {
        this.concepto = concepto;
    }

   public boolean getPagado() {
       return pagado;
   }
    
    
    public String getPagadoStr() {
        if(pagado==true){
           return "Si";
        }else{
            return "No";
        }
    }

    public void setPagado(boolean pagado) {
        this.pagado = pagado;
    }

    public Usuarios getUsuarioIDfk() {
        return usuarioIDfk;
    }

    public void setUsuarioIDfk(Usuarios usuarioIDfk) {
        this.usuarioIDfk = usuarioIDfk;
    }

    public Cuentas getCtaIDfk() {
        return ctaIDfk;
    }

    public void setCtaIDfk(Cuentas ctaIDfk) {
        this.ctaIDfk = ctaIDfk;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (diarioID != null ? diarioID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Diario)) {
            return false;
        }
        Diario other = (Diario) object;
        if ((this.diarioID == null && other.diarioID != null) || (this.diarioID != null && !this.diarioID.equals(other.diarioID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        //return "Entities.Diario[diarioID=" + diarioID + "]";
        if(pagado==true){
           return "Si";
        }else{
            return "No";
        }

        //return diarioID.toString();

    }

}
